package com.eurasia.assignment.service;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eurasia.assignment.domain.Submission;
import com.eurasia.assignment.infrastructure.entity.SubmissionEntity;
import com.eurasia.assignment.infrastructure.repository.SubmissionRepository;
import com.eurasia.assignment.service.port.in.GetProjectSubmissionsUseCase;

import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class GetProjectSubmissionsService implements GetProjectSubmissionsUseCase {
    private final SubmissionRepository submissionRepository;

    @Override
    @Transactional(readOnly = true)
    public List<Submission> getAllSubmissionsByProjectId(Long projectId) {
        List<SubmissionEntity> submissions = submissionRepository.findByProjectId(projectId);
        return submissions.stream()
                .map(SubmissionEntity::toDomain)
                .collect(Collectors.toList());
    }
} 